package com.hbnu.iostream;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author kittychen
 * @date 2025-09-30 17:31
 */
public class InputStreamReaderDemo {

    public static void main(String[] args) {
        String path = "E:" + File.separator + "2309" + File.separator + "2309.txt";
        File file = new File(path);

        InputStreamReader reader = null;

        try {
            reader = new InputStreamReader(new FileInputStream(file));

            char[] buf = new char[1024];

            int len = 0;
            int temp;
            while ((temp = reader.read()) != -1) {
                buf[len++] = (char) temp;
            }
            System.out.println(new String(buf, 0, len));
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (reader != null) {
                    reader.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
